package com.ruoyi.web.wapper;

import cn.hutool.core.util.DesensitizedUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.wapper.BaseControllerWrapper;
import com.ruoyi.market.enums.SpecialEnum;
import org.apache.commons.lang3.ObjectUtils;

import java.util.List;
import java.util.Map;

public class MemberExtInfoWapper extends BaseControllerWrapper {

    public MemberExtInfoWapper(Map<String, Object> single) {
        super(single);
    }

    public MemberExtInfoWapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {

            Long uid = (Long) map.get("uid");
            if (ObjectUtils.isNotEmpty(uid)){
                map.put("uid", String.valueOf(uid));
            }

            String mobile = (String) map.get("mobile");
            if (StrUtil.isNotEmpty(mobile)){
                map.put("mobile", "");
                map.put("mobileStr", DesensitizedUtil.mobilePhone(mobile));
            }

            String idCard = (String) map.get("idCard");
            if (StrUtil.isNotEmpty(idCard)){
                map.put("idCard", "");
                map.put("idCardStr", DesensitizedUtil.idCardNum(idCard, 3,4));
            }

            String username = (String) map.get("username");
            if (StrUtil.isNotEmpty(username)){
                map.put("username", "");
                map.put("usernameStr", DesensitizedUtil.chineseName(username));
            }

            String loanAmount = (String) map.get("loanAmount");
            if (StringUtils.isNotEmpty(loanAmount)){
                map.put("loanAmount", SpecialEnum.LoanAmount.getNameByValue(loanAmount));
            }

            String zhimaScore = (String) map.get("zhimaScore");
            if (StringUtils.isNotEmpty(zhimaScore)){
                map.put("zhimaScore", SpecialEnum.ZhimaScore.getNameByValue(zhimaScore));
            }

            String yuqi = (String) map.get("yuqi");
            if (StringUtils.isNotEmpty(yuqi)){
                map.put("yuqi", SpecialEnum.Yuqi.getNameByValue(yuqi));
            }

            String baitiao = (String) map.get("baitiao");
            if (StringUtils.isNotEmpty(baitiao)){
                map.put("baitiao", SpecialEnum.BaiTiao.getNameByValue(baitiao));
            }

            String huabei = (String) map.get("huabei");
            if (StringUtils.isNotEmpty(huabei)){
                map.put("huabei", SpecialEnum.HuaBei.getNameByValue(huabei));
            }

            String gjj = (String) map.get("gjj");
            if (StringUtils.isNotEmpty(gjj)){
                map.put("gjj", SpecialEnum.Gjj.getNameByValue(gjj));
            }

            String house = (String) map.get("house");
            if (StringUtils.isNotEmpty(house)){
                map.put("house", SpecialEnum.House.getNameByValue(house));
            }

            String car = (String) map.get("car");
            if (StringUtils.isNotEmpty(car)){
                map.put("car", SpecialEnum.Car.getNameByValue(car));
            }

            String insurance = (String) map.get("insurance");
            if (StringUtils.isNotEmpty(insurance)){
                map.put("insurance", SpecialEnum.Insurance.getNameByValue(insurance));
            }

            String socialInsurance = (String) map.get("socialInsurance");
            if (StringUtils.isNotEmpty(socialInsurance)){
                map.put("socialInsurance", SpecialEnum.SocialInsurance.getNameByValue(socialInsurance));
            }

            String enterpriseOwner = (String) map.get("enterpriseOwner");
            if (StringUtils.isNotEmpty(enterpriseOwner)){
                map.put("enterpriseOwner", SpecialEnum.EnterpriseOwner.getNameByValue(enterpriseOwner));
            }

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
